﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KOPLibrary.DataManagement.Cacheflow;

namespace KOPLibrary.Forms.CashFlow
{
    public partial class MainAccounts : CacheflowUserControlBase
    {
        public MainAccounts()
        {
            InitializeComponent();
        }

        internal BindingSource BindingSource
        {
            get
            {
                return ana_HesapBindingSource;
            }
        }

        private void ana_HesapBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {

            Commit();
            

        }

        public override void Commit()
        {
            base.Commit();
            this.Validate();
            this.ana_HesapBindingSource.EndEdit();
            DataLayer.SaveCachflowData(currentDataSource);
            //this.tableAdapterManager.Ana_HesapTableAdapter.Update(currentDataSource.Ana_Hesap);
        }

        private void ana_HesapDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        public override void Bind(Cacheflow.CacheflowDs ds)
        {
            ana_HesapBindingSource.DataSource = ds;
            base.Bind(ds);
        }

        private void ana_HesapBindingNavigator_RefreshItems(object sender, EventArgs e)
        {

        }

        private void ana_HesapBindingSource_DataError(object sender, BindingManagerDataErrorEventArgs e)
        {
            
        }

        private void ana_HesapBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            DataRowView rView = (ana_HesapBindingSource.List as DataView).AddNew();
            rView.Row["ID"] = Guid.NewGuid();
            e.NewObject = rView;
        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            Commit();
        }
    }
}
